{
    let env = new Env();
    let rl = new Rl({
        actions: ["left", "right", "up", "down"],
        states: [],
        learningRate: 0.01, //learning rate
        rewardDecay: 0.9, //reward decay
        eGreedy: 0.9,  // greed rate
    });

    let observation = "";
    let _observation = "";
    let action = "";
    let _action = "";
    let reward = "";
    let done = false;
    let isTerminated = false;

    // initial observation
    observation = env.reset();
    action = rl.chooseAction(_observation);
    let timer = setInterval(function () {

        if ( isTerminated ) {
            // break while be terminated of this learn
            window.clearInterval(timer);
            return false;
        }

        if ( done ) {
            // initial observation
            observation = env.reset(function () {
                console.table(rl.getQtabel());
                _observation = "";
                done = false;
            });
        } else {
            // RL choose action based on observation
            

            // RL take action and get nex observation and reward
            let stepRes = env.step(action);
            _observation = stepRes.observation;
            reward = stepRes.reward;
            done = stepRes.done;

            _action = rl.chooseAction(_observation);

            // RL learn from this transition
            rl.learn(observation, action, reward, _observation, _action);

            // swap observation
            observation = _observation;
            action = _action;
        }
    },500);



}